<?php
    echo $this->Html->script('chat-1.0');
?>

<script type="text/javascript">
    $(document).ready(function(){
        initChat('<?php echo $this->webroot;?>');        
    });
</script>

<div id="chatMessages">
    <input type="hidden" value="<?php echo $placeId;?>" id="placeId"> 
<?php
$i = count($data);
while($i > 0){
    $i--;
    $d = $data[$i];
    $msg = $d['ChatsMessage']['content'];
?>
    <div class="chatMessage">
        <input type="hidden" class="idChatMessage" value="<?php echo $d['ChatsMessage']['id'];?>"/>
        <div class="">
            <div class="col6 left">
                <div class="user">
                <?php echo $this->Display->link($d['User'], 'User');?> 
                </div>
            </div>
            <div class="col3 right">
                <div class="date">
                    <span class="date"><?php echo $this->Date->getDisplay($d['ChatsMessage']['posted_on']);?></span>
                </div>
            </div>
        </div>
        <div class="clear content">
                <p>
                    <?php echo $msg;?>
                </p>
        </div>
    </div>
<?php
}

?>
</div>

<?php
echo $this->Form->create('Chats', array('action' => 'add', 'id' => 'formChat'));
echo $this->Form->input('content', array(
    'type' => 'textarea',
    'id' => 'contentSendPost',
    'label' => ''
));
echo $this->Form->submit('Add', array(    
    'id' => 'buttonSendPost'
));
echo $this->Form->end();
?>